﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

public partial class testPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //DataOperation DBO = new DataOperation();
        //string FilePath=DBO.CheckDirectory("JCZL");
        //Response.Write(FilePath);
        //CheckFlow CF=new CheckFlow();


        //if (CF.CheckIsMyFlow("user3", "LCJC2009080006"))
        //{
        //    Response.Write("YES");
        //}
        //else
        //{
        //    Response.Write("NO");
        //}
        //messages Ms = new messages();
        //Ms.Title = "tffddsf";
        //Ms.Content = "gdfgdsgdgfgdgfddfgdg";
        //Ms.FromUserName = "tylz";
        //Ms.ToUserName = "admin";
        //Ms.TrueFlowID = "LCJC2009080001";
        //Ms.SendCheckDataMessage();
        //Response.AddHeader("content-disposition", "attachment; filename=systemInfo.html");
        //string depName = BasicClass.GetDepNameByDataID("JC2009080002");
        //Response.Write(depName);
        //Response.Write(BasicClass.GetRoleNameByRoleID(4));
        //DataOperation dataO = new DataOperation();
        //dataO.DelData("JC2009100001", Server.MapPath("files").ToString());
        //DataOperation.GetCurrentOperatorByDataID("JC2009100004");
        Label2.Text = DateTime.Now.ToString();
        

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string UpFilePath = FileUploadDaTa.PostedFile.FileName.ToString().Trim();
        if (UpFilePath != "")
        {
            try
            {
                string filePath = UpDataFile();
                Response.Write("<script language='javascript'>alert('文件上传成功！');</script>");
                

            }
            catch (Exception ex)
            {
                Response.Write("<script language='javascript'>alert('文件上传失败！请重新上传');</script>");
                throw (ex);                

            }

        }



    }
    private string UpDataFile()
    {       
        string fullFileName = FileUploadDaTa.PostedFile.FileName.ToString().Trim();
        string type = fullFileName.Substring(fullFileName.LastIndexOf(".") + 1).ToLower();
        string SaveFilename = fullFileName.Substring(fullFileName.LastIndexOf("\\") + 1);
        if (type == "exe")
        //if (type.ToString() != "jpg" && type != "jpeg" && type != "bmp" && type != "gif" && type != "png")
        {
            Response.Write("<script language='javascript'>alert('文件格式不对！');</script>");
        }
        else
        {
            DataOperation DBO = new DataOperation();
            string FilePath = DBO.CheckDirectory("JCZL");
            string DataFilePath = FilePath+"\\" + SaveFilename;
            if(File.Exists(Server.MapPath("files") + DataFilePath))
            {
                Response.Write("<script language='javascript'>alert('文件重名，请重命名文件后再上传！');</script>");
            }
            else
            {
            FileUploadDaTa.PostedFile.SaveAs(Server.MapPath("files") + DataFilePath);
            return DataFilePath;
            }

        }
        return null;
    }

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Label1.Text = DropDownList1.SelectedValue;
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        //BasicClass BC = new BasicClass();
        //string tempString=BC.HtmlEncode(TextBox1.Text);
        //TextBox2.Text = BC.HtmlDiscode(tempString);
        //Label3.Text = tempString;
    }
}
